<%@page import="models.OrderProductModel"%>
<%@page import="java.util.TreeMap"%>
<%@page import="helpers.DateHelper"%>
<%@page import="models.OrderFeedbackModel"%>
<%@page import="java.util.List"%>
<%@page import="data.OrderFeedbackData"%>
<%@page import="data.GeoData"%>
<%@page import="models.UserModel"%>
<%@page import="data.UserData"%>
<%@page import="data.DealData"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@page import="java.util.Calendar"%>
<%@page import="models.OrderModel"%>
<%@page import="java.util.Locale"%>
<%@page import="java.text.NumberFormat"%>
<%@page import="models.DealModel"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%
	OrderModel order = (OrderModel)request.getAttribute("order");
	UserModel user = (UserModel)request.getAttribute("user");			
	NumberFormat nf = NumberFormat.getNumberInstance(Locale.GERMAN); 	
%>
<jsp:include page="/layouts/header.jsp">
	<jsp:param name="language" value="1" />	
</jsp:include>	 
        <div id="content_inner">
            	<div id="productDetailInfo" class="clearafter">
            		<%
            			if(order!=null){            				
            				SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy, HH:mm:ss");            				       				
            		%>
                	<div class="left">                    	
                    	<div id="ordersInfo">
							<h1>Thông tin đơn hàng</h1>
                            <div class="content-right">
                            	<a href="/don-hang/in/<%=order.getOrderId() %>" class="button blue">In đơn hàng</a>                               
                            </div>
                            <div class="orderStatus">                            	
                            	<p><strong>Đơn hàng:</strong> 	<%=order.getOrderId() %></p>
                                <p><strong>Ngày:</strong> 	<%=dateFormat.format(order.getOrderDate())%></p>
								<p><strong>Trạng thái:</strong>
									<%
										switch (order.getStatus()) {
											case 1: 
												%>Chưa xác nhận<%
												break;										
											case 2:
												%>Đã xác nhận<%
												break;
											case 3:
												%>Đang giao hàng<%
												break;
											case 4:
												%>Đã hoàn thành<%
												break;
											case 7:
												%>Kiểm tra lại<%
												break;
											case 5:
												%>Đã huỷ<%
												break;	
											case 8:
												%>Khoá<%
												break;	
											case 11:
												%>Đã thanh toán<%
												break;	
											default:
												%>Chưa kích hoạt<%
												break;											
										}
										%>
								</p>
                            </div>
                            <div>
                                <h3>Thông tin deal</h3>
                                <table cellpadding="0" cellspacing="0">
                                    <thead>
                                        <tr>
                                            <th width="60%">Deal</th>
                                            <th>Đơn giá</th>
                                            <th>Số lượng</th>
                                            <th>Thành tiền</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <tr valign="top">
                                            <td align="left">
                                                <a href="/<%=order.getDealId()%>/<%=order.getDealName()%>.html"><strong><%=order.getDealShortName() %></strong></a>
                                                <%
                                                	if(order.getListOrderProduct()!=null&&order.getListOrderProduct().size()>1){
                                                		for(String string: order.getListOrderProduct()){
                                                			OrderProductModel orderProduct = new OrderProductModel();
                                                			orderProduct.getValueFromString(string);
                                                		%>
                                                		<p><%=orderProduct.getQuantity() %> x <%=orderProduct.getName() %></p>
                                                		<%
                                                		}
                                                	}
                                                %>                                                
                                                <p class="sku">Code: <%=order.getOrderId() %></p>
                                            </td>
                                            <td><%=nf.format(order.getUnitPrice()) %>&nbsp;VNĐ</td>
                                            <td><%=order.getQuantity() %></td>
                                            <td><strong><%=nf.format(order.getTotalPrice()) %>&nbsp;VNĐ</strong></td>
                                        </tr>                                    
                                    </tbody>
                                </table>
                            </div>
                            <div>
                            	<h3>Tóm tắt</h3>
                                <div class="orderSummary">
                                	<p class="clearafter"><strong class="left">Hình thức thanh toán:</strong>
                                		<span class="right">
                                		<%
											switch (order.getPaymentType()) {
												case 1: 
													%>Thanh toán trực tiếp<%
													break;	
												case 2: 
													%>Thanh toán chuyển khoản<%
													break;	
												default:
													%>Khác<%
													break;											
											}
											%>
										</span>
                                	</p>                                    
                                    <p class="clearafter"><strong class="left">Tổng cộng:</strong>  	<strong class="right"><%=nf.format(order.getTotalPrice()) %> VNĐ</strong></p>
                                    <%
                                    	if(order.isChangeAddress()){
                                    		%>
                                    <p class="clearafter"><strong class="left">Chuyển từ : </strong><span class="right"><%=order.getOldAddress() %></span></p>
                                    <p class="clearafter"><strong class="left">Đến : </strong><span class="right"><%=order.getShipAddressFull() %></span></p>
                                    		<%
                                    	}
                                    %>
                                    <%
                                    	if(order.getNote()!=null&&order.getNote().length()>0){
                                    		%>
                                    <p class="clearafter"><strong class="left">Ghi chú khách hàng:</strong>  	<span class="right"><%=order.getNote() %></span></p>		
                                    		<%                                    		
                                    	}
                                    %>                                    
                                </div>
                            </div>
                            <div>
                            	<h3>Thông tin khách hàng</h3>
                                <div class="customerInfo">
                                	<h4>Thông tin tài khoản</h4>
                                    <p class="clearafter"><strong class="left">Email:</strong>		<span class="right"><%=order.getUsername() %></span></p>
                                    <br />
                                    <h4>Địa chỉ giao hàng</h4>
                                    <p class="clearafter"><strong class="left">Họ tên:</strong>		<span class="right"><%=order.getShipName() %></span></p>
                                    <p class="clearafter"><strong class="left">Địa chỉ:</strong>	<span class="right"><%=order.getShipAddressFull() %></span></p>
                                    <p class="clearafter"><strong class="left">Điện thoại:</strong>		<span class="right"><%=order.getShipPhoneNumber() %></span></p>
                                </div>
                            </div>                                                                                                                                  
                        </div>                        
                    </div>
                    <%
            			}
                    %>
                    <div class="right rightSideBar">
                   		<jsp:include page="/elements/right_menu.jsp"/>
                   	</div>			   					
                </div>
            </div>
<jsp:include page="/layouts/footer.jsp">
    <jsp:param name="language" value="1" />
</jsp:include>